package worlds
{
	import Level;
	import net.flashpunk.World;
	import Primitives.*;
	import physics.Physics;
	import players.Player;
	import flash.geom.Point;
	//import levelpackage.Level;
	
	/**
	 * ...
	 * @author Alex
	 */
	public class Gameworld extends World 
	{
		//[Embed(source = "LevelTest.oel", mimeType = "application/octet-stream")] private static const DEFAULT_MAP:Class;
		[Embed(source='../assets/LevelTest.oel', mimeType='application/octet-stream')] private static const DEFAULT_MAP:Class;
		public function Gameworld() 
		{
			super();
		}
		
		override public function  begin():void 
		{
			trace("Beginning World");
			//var startPos :Point = new Point;
			//add(new Player(startPos));
			var level:Level = Level(add(new Level(DEFAULT_MAP)));
			var dataList:XMLList;
			var dataElement:XML;
			//var LevelData:XML = new XML(dataString);
			
			//dataList = level.LevelData.objectLayer;//.player;
			dataList = level.LevelData.objectLayer.player;
			for each (dataElement in dataList)
			{
				var startPos :Point = new Point;
				startPos.x = int(dataElement.@x);
				startPos.y = int(dataElement.@y);
				trace(startPos.x);
				trace(startPos.y);
				add(new Player(startPos));
			}
			
			dataList = level.LevelData.objectLayer.ramp;
			for each (dataElement in dataList)
			{
				var _ramp: Ramp = new Ramp();
				_ramp.x = int(dataElement.@x);
				_ramp.y = int(dataElement.@y);
				add(_ramp);
			}
			
			
			/*var _itemA:Items = new Items();
			_itemA.x = 350;
			_itemA.y = 220;
			add(_itemA);
			
			var _rampA: Ramp = new Ramp();
			_rampA.x = 250;
			_rampA.y = 420;
			_rampA.setOrientation("left");
			var _rampB: Ramp = new Ramp();
			_rampB.x = 550;
			_rampB.y = 320;
			_rampB.setOrientation("right");
			
			var _rampC: Ramp = new Ramp();
			_rampC.x = 390;
			_rampC.y = 420;
			_rampC.setOrientation("left");
			
			
			add(_rampA);
			add(_rampB);
			add(_rampC);*/
			
			//add(new Ramp);
			add(new Physics);
			
		}

		
	}

}